<!DOCTYPE html>
<html>

<head>
    <title>日报资讯</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            var currentPage = 1;//默认第一页
            var pages; //总页数
            var newsArr = [];//用户存储游记文章的容器
            var loading = false;//标记是否查询中

            function query() {//分页查询
                if(loading){//代表正在查询,就直接结束方法
                    return;
                }
                loading = true;//标记正在查询中;
                $.get(baseUrl +"/news", {currentPage: currentPage}, function (data) {
                    $.merge(newsArr,data.list );//合并数据,把第二个参数的数据合并到第一个参数的容器中
                    var json = {list:newsArr};//用于render-loop="list"
                    $(".news").renderValues(json,{
                        getHref:getHref
                    });//使用合并后的容器来进行渲染,但是必须要有list的属性名称
                    currentPage++;//当前页数+1
                    pages = data.pages;//设置总页数
                    loading = false;//标记查询结束
                })
            }

            query();//默认查询第一页

            //监听窗口的滚动事件
            $(window).scroll(function () {
                if($(document).scrollTop()+$(window).height()>=$(document).height()-50){//滚动到底部
                    //如果已经查询到最后一页,就不再查
                    if(currentPage<=pages) {
                        query();
                    }else{
                        $(document).dialog({
                            type : 'notice',
                            content: '<span class="info-text">已经到底了!</span>',
                            autoClose: 1500
                        });
                    }
                }

            })

        })

    </script>
</head>

<body>


<div class="search-head">
    <div class="row nav-search">
        <div class="col-1">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-9">
            <div class="input-group-sm search">
                <input id="search" class="form-control" placeholder="搜索资讯">
            </div>
        </div>
        <div class="col-1">
            <i class="fa fa-search" id="searchBtn"
               style="color:white;font-size:25px;position: absolute;top: 23%;left: 88%">
            </i>
        </div>
    </div>
</div>

<div class="container news">
    <div class="news">
        <h6 class="news-title">日报资讯 </h6>
        <div class="row" render-loop="list">
            <div class="col-6">
                <a data-url="/newsContent.html?id=" render-key="list.id" render-fun="getHref">
                    <b render-html="list.title"></b>
                </a>

                <br/>
                <a data-url="/newsContent.html?id=" render-key="list.id" render-fun="getHref">
                    <img class="rounded" width="100%" height="110px"
                         render-src="list.coverUrl">
                </a>
                <br>
                <div class="caption row">
                    <div class="col-9"><span render-html="list.releaseTime"> </span></div>
                    <div class="col-3">  <i class="fa fa-heart-o handleBtn" id="loveBtn" render-html="likeNum">11 </i>
                    </div>
                    <br/>
                </div>
                <p>      </p>
            </div>

        </div>
    </div>
</div>

</body>

</html>